package cn.edu.scau.cmi.wangzm.adapter;

import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.wangzm.singleton.Chairman;
import cn.edu.scau.cmi.wangzm.singleton.Marshal;
import cn.edu.scau.cmi.wangzm.singleton.MarshalPool;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class AdapterController {
	@FXML
    private TextArea OutputField;
    @FXML
    private TextField inputField1;
    @FXML
    private TextField inputField2;
    @FXML
    private Button button;
    private static ArrayList<Student> stuLists = new ArrayList<>();
    @FXML
    void handleOk1(ActionEvent event) {
    	if(inputField1.getText().isEmpty()||inputField2.getText().isEmpty()) {OutputField.appendText("请输入完整信息\n");}
    	else {
    	String name=inputField1.getText();
    	int num=Integer.parseInt(inputField2.getText());
    	Student student=new Student();
    	student.SetName(name);
    	student.SetNum(num);
    	stuLists.add(student);
        AdapterOfClass adapterofclass=new AdapterOfClass(stuLists);
        OutputField.clear();
        for(int i=0;i<adapterofclass.getList().size();i++) {
        	OutputField.appendText("姓名："+adapterofclass.getList().get(i).GetName()+"          学号："+adapterofclass.getList().get(i).GetNum()+"     类模式添加成功"+"\n");
        }
    	}
    }
    @FXML
    void handleOk2(ActionEvent event) {
    	if(inputField1.getText().isEmpty()||inputField2.getText().isEmpty()) {OutputField.appendText("请输入完整信息\n");}
    	else {
    	String name=inputField1.getText();
    	int num=Integer.parseInt(inputField2.getText());
    	Student student=new Student();
    	student.SetName(name);
    	student.SetNum(num);
    	AdapterOfObject adapterofobject=new AdapterOfObject(student);
    	OutputField.clear();
        for(int i=0;i<adapterofobject.getList().size();i++) {
        	OutputField.appendText("姓名："+adapterofobject.getList().get(i).GetName()+"          学号："+adapterofobject.getList().get(i).GetNum()+"     对象模式添加成功"+"\n");
        }
    	}
    }
    @FXML
    void initialize() {
    }
}
